﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;

namespace Ldt.WindowsFormsApp.ToolsForm
{
    public partial class FormXmlToDocument : Form
    {
        public FormXmlToDocument()
        {
            InitializeComponent();
        }
        /// <summary>
        /// 转换
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonToDocument_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(richTextBoxSource.Text))
            {
                try
                {
                    string content=richTextBoxSource.Text.Replace("&lt;","<").Replace("&gt;",">").Replace("&quot;","\"");
                    richTextBoxTage.Text = content;
                    XmlDocument xmlDocument = new XmlDocument();
                    xmlDocument.LoadXml(content);
                    richTextBoxTage.Text=xmlDocument.OuterXml;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("数据格式不正确！");
                }
            }
            else 
            {
                MessageBox.Show("请输入要测试的数据！");
            }
        }
    }
}
